Beginning Flash Game Programming for Dummies (ISBN by 0764589628)
Author:0764589628)
Language: eng
Format: mobi
Tags: &NEW
Published: 2011-07-01T01:27:22+00:00
15_589628 ch08.qxd 10/12/05 2:51 PM Page 190
190 Part IV: Getting Control of the Situation
Controlling your own sounds
Monkeying around with Flash’s audio compres-
yourself and often produce both decent
sion is pretty easy:
sound and effective compression.
1. Right-click the sound file in the Library.
After you change the compression options,
you can click the Test button to hear how
2. Choose Properties from the contextual menu.
your audio effect sounds.
You see a dialog box like the following figure.
Tests take longer to compile when you
ߜ If you leave the compression setting to
choose better compression. (Every time you
Default, Flash decides how to compress the
test a program, Flash rebuilds the sound file
sound. When you run the program, you usu-
at the quality you request.) To keep compile
ally lose too much quality.
times reasonable, use a weaker algorithm
ߜ
while testing your programs.
If you switch the compression type to MP3,
you can play with the compression rates
ߜ Switch to a better (but slower) algorithm for
your final build.
Incorporating sound into your programs
Typically, you break your sound coding into three steps: 1. Gather and configure the sounds in the Flash editor.
2. Write initialization code to set up the Sound objects.
3. Play the sounds in response to events in the game.
15_589628 ch08.qxd 10/12/05 2:51 PM Page 191
Chapter 8: Keyboard Input and Audio Output
191
Listing 8-2 shows how the soundDemo ties all these ideas together.
Listing 8-2:
Sound Demo
//soundDemo
//illustrates how to add code-driven sound to
//games
//Andy Harris, 4/05
//assumes a file called “crash.wav” has been loaded into library
//with link settings changed to “export for actionscript”
init();
function init(){
//create a sound object
sndCrash = new Sound();
sndCrash.attachSound(“crash.wav”);
} // end init
btnCrash.onRelease = function(){
sndCrash.start();
} // end
If you have many sounds, initialize them all in the init() method. (I often immediately play a sound to ensure it’s working before I move the sound’s start code to another place.)
Getting the most from your sounds
Sound is important, but it can be tricky to work with. Any resource that makes your game larger needs to have an adequate payoff. Here are the most important things to remember when working with sound files in Flash: ߜ Don’t use long songs. Background music can dramatically lengthen your game’s download time, and it gets annoying quickly. Many people turn off background music, so don’t use it unless it’s really important to your game.
If you need music, look for short loops of music that can be repeated.
Audio in Flash games is better used with either special effects or instruction and splash screens.
ߜ Import MP3 files. If you’re pretty handy with audio, you might want to do your own MP3 conversions. If you load an MP3 file directly into Flash, the Use Imported MP3 Quality check box of the Properties dialog box is activated. This setting means
• You do all your tweaking in your audio tool.
• Flash plays your file at the settings you mandate.
15_589628 ch08.qxd 10/12/05 2:51 PM Page 192
192 Part IV: Getting Control of the Situation
If you don’t enable the Use Imported MP3 Quality check box, Flash tries to optimize your already optimized MP3 file (and often makes a mess of things).
ߜ Flash doesn’t love all rates and settings. If
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12647)
Hello! Python by Anthony Briggs(9948)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9825)
The Mikado Method by Ola Ellnestam Daniel Brolund(9814)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(9719)
Dependency Injection in .NET by Mark Seemann(9369)
Hit Refresh by Satya Nadella(8856)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8334)
The Kubernetes Operator Framework Book by Michael Dame(7945)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7811)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7791)
Exploring Deepfakes by Bryan Lyon and Matt Tora(7735)
Grails in Action by Glen Smith Peter Ledbrook(7722)
Practical Computer Architecture with Python and ARM by Alan Clements(7678)
Implementing Enterprise Observability for Success by Manisha Agrawal and Karun Krishnannair(7645)
Robo-Advisor with Python by Aki Ranin(7630)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7592)
Building Low Latency Applications with C++ by Sourav Ghosh(7521)
Svelte with Test-Driven Development by Daniel Irvine(7499)
